package com.gingko.duominuo.ui.activity

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import com.gingko.duominuo.R
import com.gingko.duominuo.databinding.ActivityReviewWorkOrderBinding
import com.gingko.duominuo.databinding.ActivityTestBinding
import com.gingko.duominuo.ui.adapter.BrowserAdapter
import com.gingko.duominuo.ui.fragment.WebViewFragment
import com.gingko.duominuo.ui.fragment.X5KernelFragment

class TestActivity : AppCompatActivity() {
    private val mViewBinding by lazy { ActivityTestBinding.inflate(layoutInflater) }
    private val fragments by lazy { mutableListOf<Fragment>() }
    private val browserAdapter by lazy { BrowserAdapter(fragments, this) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(mViewBinding.root)
        initData()
        mViewBinding.vpContent.offscreenPageLimit = 1
        mViewBinding.vpContent.adapter = browserAdapter
        mViewBinding.vpContent.currentItem = 1
    }

    private fun initData() {
        for (x in 0..10) {
            fragments.add(WebViewFragment.newInstance("https://v.douyin.com/J3RV76X/"))
        }
        browserAdapter.notifyDataSetChanged()
    }

    companion object {
        @JvmStatic
        fun start(context: Context) {
            val starter = Intent(context, TestActivity::class.java)
            context.startActivity(starter)
        }
    }
}